<header class="header navbar bg-white shadow">
  <div class="btn-group tool-button">
    <a class="btn btn-primary navbar-btn" href="/private/shop/goods/class" data-pjax id="goback"><i class="ti-angle-left"></i> 返回</a>
  </div>
</header>

<div class="content-wrap">
  <div class="wrapper" style="min-height:500px;">
    <section class="panel panel-form">
      <form id="unitAddForm" role="form" class="form-horizontal parsley-form" data-parsley-validate
            action="/private/shop/goods/class/editDo" method="post">
        <input type="hidden" id="id" name="id" value="<%=obj.id%>">
        <div class="row mb10">
          <div class="col-lg-12">
            <div class="form-group has-feedback">
              <label for="parentId" class="col-sm-2 control-label">上级分类</label>

              <div class="col-sm-8">
                  <input id="parentId" type="text" class="form-control" placeholder="顶级分类" disabled
                         value="<%=typeof parentUnit!='undefined'?parentUnit.name:'' %>"/>
                <input type="hidden" name="parentId" value="<%=typeof parentUnit!='undefined'?parentUnit.id:0 %>">
              </div>
            </div>
            <div class="form-group">
              <label for="typeid" class="col-sm-2 control-label">商品类型</label>

              <div class="col-sm-8">
                <select id="typeid" name="typeid" class="form-control">
                  <option value="0">通用商品</option>
                  <%if(typelist){
                    typelist.forEach(function(o){
                  %>
                  <option value="<%=o.id%>" <%=obj.typeid==o.id?'selected':''%>><%=o.name%></option>
                  <%
                  });
                  }%>
                </select>
              </div>
            </div>
            <div class="form-group">
              <label for="name" class="col-sm-2 control-label">分类名称</label>

              <div class="col-sm-8">
                <input type="text" id="name" class="form-control" name="name" data-parsley-required="true"
                       placeholder="分类名称" value="<%=obj.name||''%>">
              </div>
            </div>
            <!--<div class="form-group">-->
              <!--<label for="title" class="col-sm-2 control-label">网页标题</label>-->

              <!--<div class="col-sm-8">-->
                <!--<input type="text" id="title" class="form-control" name="title"-->
                       <!--placeholder="title"  value="<%if(obj.settings){%><%=obj.settings.title%><%}%>">-->
              <!--</div>-->
            <!--</div>-->
            <!--<div class="form-group">-->
              <!--<label for="keywords" class="col-sm-2 control-label">网页关键词</label>-->

              <!--<div class="col-sm-8">-->
                <!--<input type="text" id="keywords" class="form-control" name="keywords"-->
                       <!--placeholder="keywords"  value="<%if(obj.settings){%><%=obj.settings.keywords%><%}%>">-->
              <!--</div>-->
            <!--</div>-->
            <!--<div class="form-group">-->
              <!--<label for="description" class="col-sm-2 control-label">网页描述</label>-->

              <!--<div class="col-sm-8">-->
                <!--<input type="text" id="description" class="form-control" name="description"-->
                       <!--placeholder="description"  value="<%if(obj.settings){%><%=obj.settings.description%><%}%>">-->
              <!--</div>-->
            <!--</div>-->
            <div class="form-group">
              <label for="enabled" class="col-sm-2 control-label">是否禁用</label>
              <div class="col-sm-8 switcha">
                <div class="mr15">
                  <input type="checkbox" id="disabled" name="disabled" <%=obj.disabled?'checked':''%> class="js-switch-red" >
                </div>
              </div>
            </div>
            <div class="form-group">
              <label for="enabled" class="col-sm-2 control-label">首页展示</label>
              <div class="col-sm-8 switcha">
                <div class="mr15">
                  <input type="checkbox" id="is_index" name="is_index" <%=obj.is_index?'checked':''%> class="js-switch-blue" >
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="col-lg-3"></div>
        <div class="col-lg-6">
          <div class="form-group text-center">
            <label></label>

            <div>
              <button class="btn btn-primary btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
            </div>
          </div>
        </div>
      </form>
    </section>

  </div>
</div>
<a class="exit-offscreen"></a>
<script language="JavaScript">
  $(document).ready(function () {
    myForm.init();
    $('#unitAddForm').ajaxForm({
      dataType: 'json',
      beforeSubmit: function (arr, form, options) {
        form.find("button:submit").button("loading");
      },
      success: function (data, statusText, xhr, form) {
        if (data.code==0) {
          Toast.success(data.msg);
          setTimeout(function () {
            $("#goback").trigger("click");
          }, 1000);
        } else {
          Toast.error(data.msg);
        }
        form.find("button:submit").button("reset");
      }
    });
  });
</script>
